<!DOCTYPE html>
<html>
<head>
	<title>添加子账号</title>
	<include file='public/head'>
	<style>
		.layui-legend-size{font-size:14px !important;}
		.layui-nopadding{padding:0 !important;}
		.layui-overflow{overflow:auto;}
		.layui-nomargin{margin: 0 !important;}
		.layui-bottom{border-bottom:1px solid rgb(226, 226, 226);}
		.layui-input{height:30px !important; }
		.layui-form-search-item .layui-inline{margin-bottom: 5px;} 
		.layui-form-search-item label{margin-left: 15px;}
		.layui-table-page {padding: 7px 0px 0px;}
		.layui-field-padding{border-width: 1px;padding:0 0 5px 10px;}
	</style>		
</head>
<body>
	<!-- layui-tab开始 -->
	<div class="layui-tab " lay-filter="demo-tab">
		<div class="layui-card">
			<div class="layui-card-body layui-nopadding " >
				<form class="layui-form" action="">
					<table class="layui-table" lay-skin="line">
				      <div class="layui-input-inline" style="width:50%">
				        <select name="modules" lay-filter="list" lay-verify="required" lay-search="">
				          <option value="0">直接选择或搜索选择</option>
				          {$select}
				        </select>
				      </div>
			      </table>		
				</form>
			</div>
		</div>
	</div>		

	<include file='public/scripts'>

<script type="text/javascript">
	
  	var form = layui.form;
  	var choose = {$role_id};

    //选择触发
	form.on('select(list)', function(data){
        let selectText=data.elem[data.elem.selectedIndex].text;//得到被选中的文本值
        //去空格
        selectText=selectText.replace(/\s+/g, "");
        data.elem[data.elem.selectedIndex].text=selectText;//覆盖原文本值
        choose = data.elem[data.elem.selectedIndex].value;
    });

	function tijiao(){
		data = {};
		data['user_id'] = {$id};
		data['role_id'] = choose;
		//提交
		$.ajax({
			url:"{:cmf_plugin_url('Store://admin_index/moveuser')}",
			data: data,
			type:'post',
			success:function(data){
				if (data.code == 1) {
					layer.msg(data.msg,{icon:1,time:1500},function(){
						parent.parent.layer.closeAll();
						parent.parent.location.reload(); 
					});
				} else {
					layer.msg(data.msg,{icon:2,time:1500});
				}
			},
			error:function()
			{
				layer.msg('系统错误',{icon:2,time:1500});
			}
		})
	}        

</script>

</body>
</html>			